//
//  HDIncomeViewController.m
//  HDecoration
//
//  Created by 曹群 on 15/9/13.
//  Copyright (c) 2015年 HDecoration. All rights reserved.
//

#import "HDIncomeViewController.h"
#import "HDIncomeTableViewController.h"

@interface HDIncomeViewController ()
@property(nonatomic,strong)HDIncomeTableViewController *incomeTableView;
@end

@implementation HDIncomeViewController

- (void)initUI
{
    self.incomeTableView = [[HDIncomeTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
    self.incomeTableView.view.frame = self.view.bounds;
    self.incomeTableView.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.incomeTableView.tableView.bounces = NO;
    self.incomeTableView.view.tag = 102;
    [self.view addSubview:self.incomeTableView.view];
}

- (void)updateViewController:(NSNotification *)note
{
    NSDictionary* dic=note.userInfo;
    if ([dic objectForKey:Receiver]==self.VctrID)
    {
        if (dic[@"Balance"]!=nil)
        {
            self.incomeTableView.income = [dic[@"incomeStr"] intValue];
        }
        else if (dic[@"Flow"]!=nil)
        {
            self.incomeTableView.totalArray = dic[@"dataArray"];
        }
    }
}

- (void)testDataFunc
{
    //请求我的余额
    NSDictionary* params03=@{
                                @"coach":netEngine.coachInfo.m_id,
                               };

    [netEngine RequestBalanceWithTarget:self.VctrID hudView:self.view Data:params03];
    
    //我的收支账单明细
    NSDate* date=[NSDate date];//用户选择的时间日期，测试我用的是当前时间
    NSString* dateStr=[HDUtil formatter:@"YYYY-MM" FromeDate:date];
    NSDictionary* params=@{
                             @"coach_id":netEngine.coachInfo.m_id,
                             @"yearMonth":dateStr,
                             @"page":[NSNumber numberWithInt:1],
                             @"row":[NSNumber numberWithInt:20],//每页显示多数行
                             };
    
    [netEngine RequestFlowWithTarget:self.VctrID hudView:self.view Data:params];
}

@end
